package top.korori.security;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private SysAuthInterceptor sysAuthInterceptor;

    /**
     * 配置拦截器
     *
     * @param registry 相当于拦截器的注册中心
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(sysAuthInterceptor)
                //注册自己的拦截器,并设置拦截的请求路径
                //addPathPatterns为拦截此请求路径的请求
                //excludePathPatterns为不拦截此路径的请求
                .addPathPatterns("/**")
                .excludePathPatterns("/sys/auth/login")
                .excludePathPatterns("/test/**")
                //放行Knife4j
                .excludePathPatterns("/doc.html")
                .excludePathPatterns("/swagger-resources/**")
                .excludePathPatterns("/webjars/**")
                .excludePathPatterns("/v3/api-docs/**");
    }



}
